const request = require('request'),
      wxkey   = require('./wxkey'),
      Koa     = require('koa'),
      app     = new Koa(),
      Router  = require('koa-router'),
      router  = new Router();

router.post('/getzifu',async c => {

  let access_url = `https://api.weixin.qq.com/cgi-bin/token`
                 + `?grant_type=client_credential`
                 + `&appid=${wxkey.appid}`
                 + `&secret=${wxkey.secret}`;

  request(access_url,function(error,response,body){
    let token = JSON.parse(body).access_token;
    let security_url = `https://api.weixin.qq.com/wxa/msg_sec_check`
                   + `?access_token=${token}`;
    request.post({url: security_url, form: {
      content: '特3456书yuuo莞6543李zxcz蒜7782法fgnv级'
    }},function(response,body){
      console.log(body.body)
    })
  });
  
  

});






app.use(router.routes())
   .use(router.allowedMethods());
app.listen(3007);
